#include <iostream>
using namespace std;
const int N=1e6+10;
typedef long long LL;
LL c[N];
char a[N],b[N];
int main()
{
	LL sum=0;
	LL i=1;
	LL k=1;
	cin>>a[i]>>b[i]>>c[i];
	i++;
	while(cin>>a[i]>>b[i]>>c[i])
	{
		if(a[i]&&b[i]&&c[i]==0)break;
		if(a[i]==b[i]&&c[i]-c[i-1]<=1000)
		k++;
		sum=max(sum,k);
		if(a[i]!=b[i]||c[i]-c[i-1]>1000)
		k=0;
		i++;
	}
	cout<<sum;
	return 0;
}
